const mongoose = require('mongoose')
// 连接数据库 如果不自己创建 默认test数据库会自动生成
mongoose.connect('mongodb://localhost/test')
 
// 为这次连接绑定事件
const db = mongoose.connection
db.once('error', () => console.log('Mongo connection error'))
db.once('open', () => console.log('Mongo connection successed'))
/************** 定义模式deviceListSchema **************/
const deviceListSchema = mongoose.Schema({
  name:String,
  createTime:Date,
  updateTime:Date,
  status:Boolean,
  desc:String,
	content: String,
  deviceFrom:String,
  buyer:String,
  deviceID:String,
  pageSize:Number,
  skipPage:Number,
}, { collection: 'device' });
 
/************** 定义模型Model **************/
const Models = {
  deviceList: mongoose.model('deviceList', deviceListSchema)
}
 
module.exports = Models
